package job04;

import java.io.IOException;
import java.util.StringTokenizer;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import job01.TProperties;

public class CountUvMapper extends Mapper<LongWritable, Text, Text, IntWritable> {
	private IntWritable num = new IntWritable();
	private Text word = new Text();
	@Override
	public void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
		StringTokenizer itr = new StringTokenizer(value.toString());
		while (itr.hasMoreTokens()) {
			String str = itr.nextToken().toString();
			String[] splits = str.split(TProperties.getValue("fileoutsplit"));
			word.set(splits[0]);
			num.set(Integer.parseInt(splits[2]));
			context.write(word, num);
		}
	}
}
